package com.wqm.step.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wqm.step.common.utils.JsonUtils;
import com.wqm.step.pojo.Person;
import com.wqm.step.service.PersonService;

@Controller
public class PersonController {

	@Autowired
	private PersonService personService;

	/**
	 * 查询数据的测试
	 * produces : 设置浏览器端的编码
	 * @return
	 */
	@RequestMapping(value = "/data.action", method = RequestMethod.GET, produces = { "text/html;charset=UTF-8" })
	@ResponseBody
	public String demo() {
		List<Person> list = personService.findAll();
		System.out.println("controller");
		System.out.println(JsonUtils.objectToJson(list));
		return JsonUtils.objectToJson(list);
		/* return "index"; */
	}
}
